<?php

function getGoodscat($value, $goodsmodelID = 1){
  if (empty($value)) {
		return false;
	}
	$map['cat_id'] = $value;
	$map['status'] = 1;
  $goodsmodelID = cookie('goodsmodel_id');

  $modelinfo = model('Goodsmodel')->find($goodsmodelID);
  $map['id'] = ['in', $modelinfo['goods']];

	$info = model('goods')->where($map)->order('cat_sort,update_time desc,id desc')->select();

	return $info;
}
function getCouponNum($uid){
  if (empty($uid)) {
		return false;
	}
	$map['uid'] = $uid;
	$map['status'] = 0;
	$info = model('coupon_list')->where($map)->count();

	return $info;
}

function getDzpinfo($type , $data){
  $type = config($type);
  $data = config($data);

  if($type == 0){
    $text = $data.'积分';
  }elseif ($type == 2) {
    $text = $data.'元';
  }else {
    $text = $data;
  }
  return $text;
}



/**
 * 团购开启模式
 */
function groupModel(){
  if(config('grouptimecongfig') == 1 && strtotime(config('grouptime')) > time()){
      //指定时间
    return 1;
  }elseif (config('grouptimecongfig') == 0 && date('G') >= 0 && date('G') < 23) {
    //明日配送
    return 2;
  }

}

function pstime(){
  if(groupModel() == 1){
    return date("y-m-d",strtotime(config('grouptime'))+ 3600*24).'统一配送';
  }else{
    return date("y-m-d",strtotime("+1 day")).'统一配送';
  }
}
